package com.example.demo;

import org.springframework.boot.CommandLineRunner;
import org.springframework.core.env.Environment;

import java.util.Objects;

/**
 * Author: wuhaoduan
 * Date: 2021/4/13 9:36
 */
@SuppressWarnings("unused")
public class CustomerCommandLineRuning implements CommandLineRunner {
    Environment e;

    //构造注入
    public CustomerCommandLineRuning(Environment e){
        this.e = e;
    }

    @Override
    public void run(String... args) throws Exception {
        System.out.println("利用SpringBoot自动装配的CommandLineRuning");

        //生成随机字符串
        System.out.println("生成随机字符串: ".concat(Objects.requireNonNull(e.getProperty("random."))));
    }
}
